package com.design.prototype.demo3;

public class PrototypeDemo {
    public static void main(String[] args) throws CloneNotSupportedException {
        // 创建原型汽车对象
        Car prototypeCar = new Car("Toyota", "Corolla", 2023);
        prototypeCar.addFeature("GPS Navigation");
        prototypeCar.addFeature("Bluetooth Connectivity");
        
        // 克隆原型对象来创建新的汽车
        Car car1 = (Car) prototypeCar.clone();
        car1.addFeature("Sunroof");
        
        Car car2 = (Car) prototypeCar.clone();
        car2.addFeature("Leather Seats");

        // 输出新汽车的属性和特点
        System.out.println("Car 1: " + car1.getMake() + " " + car1.getModel() + " " + car1.getYear());
        car1.printFeatures();

        System.out.println("\nCar 2: " + car2.getMake() + " " + car2.getModel() + " " + car2.getYear());
        car2.printFeatures();
    }
}
